local module = {
  insert_template = function()
    local filetype = vim.opt.filetype:get()
    local directory = vim.fn.stdpath "config" .. "/templates/" .. filetype .. "/"
    local filenames = vim.fn.readdir(directory)
    vim.ui.select(filenames, {}, function(filename)
      local lines = vim.fn.readfile(directory .. filename)
      vim.api.nvim_put(lines, "l", false, false)
    end)
  end,
}

return module
